﻿using UtilsBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Device.Gpio;
using System.Device.I2c;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using IotDeviceToolHepler;

namespace GatewayClient.Device
{
    /// <summary>
    /// 土壤湿度
    /// </summary>
    public class ServiceDeviceSoilSevice
    {
        //public static void getSoilHumidity()
        //{

        //    while (true)
        //    {
        //        try
        //        {
        //            while (true)
        //            {
        //                byte v = SensorSoilHumidityAo.GetSoilHumidity();
        //                Console.WriteLine("湿度强度值：" + v);
        //                Thread.Sleep(1000);
        //            }

        //        }
        //        catch { }

        //        Thread.Sleep(1000);
        //    }
        //}
        ///// <summary>
        ///// 获取配置
        ///// </summary>
        ///// <param name="reqIotModel"></param>
        ///// <returns></returns>
        //private static RespIotModel getConfigure(ReqIotModel reqIotModel)
        //{
        //    //请求接口
        //    HttpHelper http = new HttpHelper();
        //    //读取apiurl并更新
        //    var jsonuserApiUrl = http.HttpPost(appsettingHelper.GetSettings("lightSensor:getLightConfigure"), "jsonStr=" + JsonConvert.SerializeObject(reqIotModel));
        //    Console.WriteLine(appsettingHelper.GetSettings("base:getHostServerDevice"));
        //    Console.WriteLine(JsonConvert.SerializeObject(reqIotModel));
        //    Console.WriteLine(jsonuserApiUrl);

        //    if (jsonuserApiUrl != null)
        //    {
        //        HttpReqModel<List<RespIotModel>> datauser = JsonConvert.DeserializeObject<HttpReqModel<List<RespIotModel>>>(jsonuserApiUrl);
        //        if (datauser.data == null) return null;

        //        //获取第一条，如果有多个传感器 这里要修改
        //        return datauser.data.FirstOrDefault();
        //    }
        //    return null;
        //}

        //private static void pushData(ReqIotModel reqIotModel)
        //{
        //    //请求接口
        //    HttpHelper http = new HttpHelper();
        //    //读取apiurl并更新
        //    var jsonuserApiUrl = http.HttpPost(appsettingHelper.GetSettings("lightSensor:pushLightDeviceData"), "jsonStr=" + JsonConvert.SerializeObject(reqIotModel));
        //    Console.WriteLine(appsettingHelper.GetSettings("base:getHostServerDevice"));
        //    Console.WriteLine(JsonConvert.SerializeObject(reqIotModel));
        //    Console.WriteLine(jsonuserApiUrl);
        //}

    }
}
